package com.bianxianmao.find.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.GridView;

import com.bianxianmao.R;
import com.bianxianmao.find.AllReturnBean;
import com.bianxianmao.find.adapter.GridViewAdapter;
import com.bianxianmao.utils.Constants;
import com.google.gson.Gson;
import com.squareup.okhttp.Request;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/25.
 */

public class AllreturnActivity extends AppCompatActivity {
    private List<AllReturnBean.ReturnValueBean> list;
    private GridViewAdapter adapter;

    private GridView gridview;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_allreturn);
        list = new ArrayList<>();
        initData();
        getnet();

    }

    private void getnet() {
        String url = Constants.ALLRETURN;
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
            @Override
            public void onError(Request request, Exception e) {

            }

            @Override
            public void onResponse(String response) {
                Gson gson = new Gson();
                AllReturnBean allReturnBean = gson.fromJson(response, AllReturnBean.class);
                List<AllReturnBean.ReturnValueBean> data = allReturnBean.getReturnValue();
                Log.i("1234", "onResponse: " + data.size());
                list.addAll(data);

            }
        });
    }

    private void initData() {
        gridview = (GridView) findViewById(R.id.gridview);
        new GridViewAdapter();
        gridview.setAdapter(adapter);
    }


}
